
<table class="data">
    <thead>
        <tr>
            <th width="50px"><?php echo 'No'; ?></th>
            <th width="100px"><?php echo 'Customer no.'; ?></th>
            <th><?php echo 'Customer Name'; ?></th>
            <th class="action">&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        <?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
        <tr>
            <td colspan="4"><div class="caption">This user can see all customers.</div></td>
        </tr>
        <? else : // ถ้ามีข้อมูล ?>
            <?php $i = 0;
            foreach($this->data as $CS): ?>
                <?php
                $tableCell = array();
                $tableCell[] = ++$i;
                $tableCell[] = $CS['Customer']['cust_no'];
                $tableCell[] = $CS['Customer']['name'];
                $tableCell[] = $my->confirmLink($html->image('icon/delete.png', array('title' => 'delete', 'alt' => 'delete')), "{$this->name}/delete_contract/{$CS['UserCoH']['id']}", 'Do you want to remove \"' . $CS['Customer']['name'] . '\" from Customer contract list?', 'divUserCoH', false);
                echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
                ?>
            <?php endforeach; ?>
        <?php endif; ?>
<?php if (!empty($customers)) : // ถ้ายังมีรายการ customer ที่ไม่ได้ contract?>
        <tr>
            <td>&nbsp;</td>
            <td colspan="4">
                    <?php echo $ajax->form(null, 'post', array('update' => 'divUserCoH', 'indicator' => 'indicator', 'url' => array('controller' => 'its_users', 'action' => 'save_customer_on_hand'))); ?>
                    <?php echo $form->select('UserCoH.customer_id', $customers); ?>
    <?php echo $form->hidden('UserCoH.user_id', array('value' => $user_id)); ?>
                <span class="toolbar" style="border: none; margin: 0px;">
    <?php echo $this->element('toolbar', array('buttons' => array(array('save' => array('message' => 'Do you want to add this customer to Customer on hand for this user?'))))); ?>
                </span>
    <?php echo $form->end(); ?>
            </td>
        </tr>
<?php endif; ?>
    </tbody>
</table>
<?php //debug($this->data); ?>